package com.hzhq.contract.repo;

import com.hzhq.contract.bean.dto.UserDTO;
import com.hzhq.contract.bean.entity.User;
import org.bson.types.ObjectId;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * @Author hzhq
 * @Date 2021/3/23 11:48 上午
 * @Mail hzhq1255@163.com
 */
@Repository
public interface UserRepository extends MongoRepository<User, ObjectId> {

    Page<UserDTO> findAllByDeletedEquals(Integer deleted, Pageable pageable);


    Page<UserDTO> findAllByUsernameLikeAndDeleted(String username,Integer deleted, Pageable pageable);

    Optional<User> findByUsernameAndDeleted(String name, Integer deleted);

    Optional<User> findByUserIdAndDeleted(ObjectId userId,Integer deleted);

    Page<User> findByDeleted(Integer deleted, Pageable pageable);

}
